package com.zzx.boot.servlet.impl;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.zzx.boot.entity.table.Adsense;
import com.zzx.boot.entity.vo.AdsenseVo;
import com.zzx.boot.mapper.AdsenseMapper;
import com.zzx.boot.servlet.AdsenseService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.stream.Collectors;

/**
 * @author tan
 * @version 1.0
 * @date 2023/7/9 22:12
 */
@Service
public class AdsenseServiceImpl extends ServiceImpl<AdsenseMapper, Adsense> implements AdsenseService {
    @Override
    public List<AdsenseVo> getListByType(Integer type) {
        LambdaQueryWrapper<Adsense> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(Adsense::getType,type);
        List<Adsense> list = baseMapper.selectList(wrapper);
        List<AdsenseVo> vos = list.stream().map(item -> new AdsenseVo(item.getId().toString(), item.getSrc(), item.getUrl())).collect(Collectors.toList());
        return vos;
    }
}
